package com.hunan.yllxy.repostitory.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hunan.yllxy.repostitory.entity.ActivityInfo;
import com.hunan.yllxy.repostitory.mapper.ActivityInfoMapper;
import com.hunan.yllxy.repostitory.dao.ActivityInfoDao;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 刘华
 * @since 2025-06-20
 */
@Service
public class ActivityInfoDaoImpl extends ServiceImpl<ActivityInfoMapper, ActivityInfo> implements ActivityInfoDao {
    @Override
    public List<ActivityInfo> myList() {
        LambdaQueryWrapper<ActivityInfo> query = Wrappers.lambdaQuery(this
                .entityClass);
        query.orderByDesc(ActivityInfo::getUpdateTime);
        return baseMapper.selectList(query);
    }

    @Override
    public ActivityInfo lastActivity() {
        LambdaQueryWrapper<ActivityInfo> query = Wrappers.lambdaQuery(this.entityClass);
        query.orderByDesc(ActivityInfo::getUpdateTime);
        query.last(" LIMIT 1 ");
        return baseMapper.selectOne(query);
    }
}
